package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    /*
    * 根据ids查询套餐菜品关系数据
    * */
    @Select("select count(id) from setmeal_dish where dish_id in (#{ids})")
    Integer countByDishId(List<Long> ids);

    /*
    * 根据套餐id删除套餐菜品关系数据
    * */
    @Delete("delete from setmeal_dish where setmeal_id = #{id}")
    void deleteById(Long id);

    /*
    * 新增套餐中的菜品
    * */
    @AutoFill(OperationType.INSERT)
    void insertSetmealDish(List<SetmealDish> setmealDishes);

    /*
    * 根据套餐id查询菜品
    * */
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<DishItemVO> getDishItemById(Long id);
}
